﻿using System;

namespace HeroldIT.Dnn.Modules
{
    /// <summary>
    /// Represents the event arguments for creating a new HierarchyObject.
    /// </summary>
    /// <typeparam name="T">The type contained in the <see cref="HierarchyObject{T}"/>.</typeparam>
    public class HierarchyObjectCreateEventArgs<T> : EventArgs
    {
        #region properties

        /// <summary>
        /// Gets the string representation of the <see cref="Object"/>.
        /// </summary>
        public string ObjectString
        {
            get; private set;
        }

        /// <summary>
        /// Gets whether an object has been set.
        /// </summary>
        public bool ObjectSet
        {
            get; private set;
        }

        private T @object;

        /// <summary>
        /// Gets or sets the object created from the string representation.
        /// </summary>
        public T Object
        {
            get { return this.@object; }
            set
            {
                this.@object = value;
                this.ObjectSet = true;
            }
        }

        #endregion

        #region constructors

        /// <summary>
        /// Creates new <see cref="HierarchyObjectCreateEventArgs{T}"/> with the given object string representation.
        /// </summary>
        /// <param name="objectString">The string representation of the object to create.</param>
        public HierarchyObjectCreateEventArgs(string objectString)
        {
            this.ObjectString = objectString;
        }

        #endregion
    }
}
